package com.hinnotek.amoeba.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogView;


/**
 * desripbe CustomDialogBuilder
 */
public class MyCustomDialogBuilder extends QMUIDialog.CustomDialogBuilder {

    private int mLayoutId;
    private View dialogView;

    public MyCustomDialogBuilder(Context context) {
        super(context);
    }

    /**
     * 设置内容区域的 layoutResId
     */
    public MyCustomDialogBuilder setLayout(@LayoutRes int layoutResId) {
        mLayoutId = layoutResId;
        return this;
    }

    public MyCustomDialogBuilder setLayout(View dialogView) {
        this.dialogView = dialogView;
        return this;
    }

    @Nullable
    @Override
    protected View onCreateContent(QMUIDialog dialog, QMUIDialogView parent, Context context) {
        if (dialogView == null) {
            dialogView = LayoutInflater.from(context).inflate(mLayoutId, parent, false);
        }
        return dialogView;
    }

}
